
module(...,package.seeall)

local pub_topic = "air202/out"

--- MQTT客户端数据接收处理
-- @param mqttClient，MQTT客户端对象
-- @return 处理成功返回true，处理出错返回false
-- @usage mqttInMsg.proc(mqttClient)
function proc(mqttClient)
    local result,data
    while true do
        result,data = mqttClient:receive(2000)
        --接收到数据
        if result then
            log.info("mqttInMsg.proc",data.topic,data.payload)
                
            --TODO：根据需求自行处理data.payload
            mqttClient:publish(pub_topic, "HelloWorld");
        else
            break
        end
    end
	
    return result or data=="timeout"
end